﻿using System;
using System.Collections.Generic;
using IFRS.DataAccess.DAL;
using IFRS.Models;
using IFRS.Web;

public partial class IFRS_WIN28_3V : PageBase
{
    #region === Event ===

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ViewMenu();
            BindControl();
            BindData();
        }
        else
            ClientScript.RegisterHiddenField("isPostBack", "1");
    }
    protected void btnCANCEL_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/IFRS/WIN28_1S.aspx");
    }

    #endregion

    #region === Method ===

    private void ViewMenu()
    {
        MenuTitleBar = Resources.ifrsMenu.WIN28_3V;
    }
    private void BindControl()
    {
        SetControlReadOnly(form_control);
    }
    private void BindData()
    {
        if (Convert.ToString(Request.QueryString["id"]) != string.Empty)
        {
            var id = Convert.ToInt32(Request.QueryString["id"]);
            var dt = new SPR_GLACCOUNT().SEARCH_BYID(id);
            if (dt != null && dt.Rows.Count > 0)
            {
                var list = new List<GLAccount>();
                ConvertHelper.ConvertDataTableToObject(dt, list);

                txtPrevGLAccountCode.Text = list[0].PrevGLAccountCode;
                txtGLAccountCode.Text = list[0].GLAccountCode;
                txtPrevGLAccountName.Text = list[0].PrevGLAccountName;
                txtGLAccountName.Text = list[0].GLAccountName;
                rbtIsActive.SelectedValue = list[0].IsActive ? "1" : "0";
            }
        }
    }

    #endregion
}